#include "Intersection.h"

Intersection::Intersection() {
    this->t = -1.0;
}

Intersection::Intersection(float t, const Vector3f& pos, const Vector3f& n) {
    this->t = t;
    this->pos = pos;
    this->n = n;
    this->n_s = n;
}

Intersection::Intersection(float t, const Vector3f& pos, const Vector3f& n, const Vector3f& n_s) {
    this->t = t;
    this->pos = pos;
    this->n = n;
    this->n_s = n_s;
}

bool Intersection::exists() const {
    return t >= 0.0;
}

bool Intersection::operator<(const Intersection& intersection) const {
    return exists() && (!intersection.exists() || t < intersection.t);
}

bool Intersection::operator<=(const Intersection& intersection) const {
    if (exists()) {
        return !intersection.exists() || t <= intersection.t;
    } else {
        return !intersection.exists();
    }
}
